package designpattern.template.jdbc;

import designpattern.template.jdbc.dataobject.Role;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class RoleMapper extends JdbcTemplate{
    public List<Role> list(String sql) throws SQLException {
       return executeQuery(sql, new RowMapper<Role>() {
            @Override
            public Role mapRow(ResultSet resultSet) throws SQLException {
                return Role.builder().roleName(resultSet.getString("role_name"))
                        .uuid(resultSet.getString("uuid"))
                        .id(resultSet.getLong("id")).build();
            }
        });
    }
}
